//package com.mytijian.task.selector;
//
//import com.google.common.base.Charsets;
//import com.mytijian.task.zookeeper.LeaderService;
//import com.mytijian.task.zookeeper.ZookeeperRegistryCenter;
//import org.apache.curator.framework.CuratorFramework;
//import org.apache.curator.framework.recipes.leader.LeaderLatch;
//import org.apache.zookeeper.CreateMode;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class SelectorClient2 {
//    private static String root = "/test";
//    private static String latch = root + "/latch";
//    public static void main(String[] args) throws Exception {
//        List<LeaderLatch> latches = new ArrayList<>();
//        List<CuratorFramework> clients = new ArrayList<>();
//        ZookeeperRegistryCenter registryCenter = new ZookeeperRegistryCenter();
//        registryCenter.init();
//        for (int i = 0 ; i < 2; i++ ) {
//            Thread thread = new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    LeaderService leaderService = new LeaderService(registryCenter,8080);
//                    leaderService.executeInLeader();
//                }
//            });
//            thread.start();
//
//        }
//        Thread.sleep(100000);
//        registryCenter.destory();
////        for (LeaderLatch latch : latches) {
////            if(latch.hasLeadership()){
////                latch.destory();
////            }
////        }
////        Thread.sleep(10000);
////        for (LeaderLatch latch : latches) {
////            if(latch.hasLeadership()){
////                latch.destory();
////            }
////        }
////        for (CuratorFramework client : clients) {
////            System.out.println(client.getData() + " is destory");
////            client.destory();
////        }
//
//
//    }
//    public static void create(CuratorFramework curatorFramework , String key, String value) {
//        try {
//            curatorFramework.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Charsets.UTF_8));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//    }
//}
